import { Component, OnInit } from '@angular/core';
import { NbSidebarService, NbThemeService } from '@nebular/theme';
import { Router } from '@angular/router';
import { MENU_ITEMS } from './pages-menu';

@Component({
  selector: 'app-pages',
  templateUrl: './pages.component.html',
  styleUrls: ['./pages.component.scss']
})
export class PagesComponent implements OnInit {

  menu = MENU_ITEMS;

  themes = [
    {
      value: 'default',
      name: 'Light',
    },
    {
      value: 'dark',
      name: 'Dark',
    },
    {
      value: 'cosmic',
      name: 'Cosmic',
    },
    {
      value: 'corporate',
      name: 'Corporate',
    },
  ];

  currentTheme = 'default';

  constructor(
    private sidebarService: NbSidebarService,
    private themeService: NbThemeService,
    private router: Router
  ) {}

  ngOnInit(): void {
    this.currentTheme = this.themeService.currentTheme;
    this.router.navigate(['pages/dashboard']);

    // 移除动画节点
    const spinner = document.getElementById('nb-global-spinner');
    spinner.parentElement.removeChild(spinner);
  }

  changeTheme(themeName: string) {
    this.themeService.changeTheme(themeName);
  }

  toggle() {
    this.sidebarService.toggle(true);
    return false;
  }
}
